package com.woniuxy.main.handler;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.dsna.util.images.ValidateCode;
@Controller
@RequestMapping("/PictureCode")
public class PictureCodeController {
	@RequestMapping("/loginCode")
	@ResponseBody
	public void getCode(HttpServletRequest request,HttpServletResponse response){
		ValidateCode code= new ValidateCode(300,40,4,17);
		//获取验证码
		String codeVal=code.getCode();
		//得到session
		HttpSession session=request.getSession();
		//把验证码存入session
		session.setAttribute("loginCode", codeVal);
		//将图形化验证码响应给客户端
		try {
			code.write(response.getOutputStream());
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
